package gui.cliente;

import dao.ClienteDAO;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ConsultarCliente extends HttpServlet {

    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        
        response.setContentType("text/html;charset=UTF-8");
        PrintWriter out = response.getWriter();
        ClienteDAO bd = new ClienteDAO();
        String rfc;
        
        String tabla;
        
        rfc = request.getParameter("rfc");               
                
        List<String> lista = bd.Juan(rfc);
        
        if(lista.isEmpty())
        {
            out.println("<h1>No tiene</h1>");
        }
        else
        {
                     tabla = "<table width='60%' border='0' cellspacing='5'> "+
                             "<tr>"+
                                "<td width='20%'><div align='right'>R.F.C.</div></td>"+
                                "<td width='20%'>"+lista.get(0)+"</td>"+
                                "<td width='20%'>&nbsp;</td>"+
                                "<td width='20'><input type='button' id='actualizar' value='Actualizar' onclick=\"ventanaNueva('ActualizarConsultar_Cliente?rfc="+rfc+"',600,530)\"/></td>"+
                                "<td width='20'><input type='button' id='eliminar' value='Eliminar' onclick=\"ventanaNueva('actualizarCliente.jsp',600,530)\"/></td>"+                                
                             "</tr>"+
                             "<tr>"+
                                "<td>&nbsp;</td>"+
                                "<td>&nbsp;</td>"+
                                "<td>&nbsp;</td>"+
                                "<td width='20%'>&nbsp;</td>"+
                                "<td width='20%'>&nbsp;</td>"+                                
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Nombre:</div></td>"+
                                "<td colspan='3'>"+lista.get(1)+"</td>"+
                                "<td width='20%'>&nbsp;</td>"+
                                
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Teléfono:</div></td>"+
                                "<td>"+lista.get(2) +"</td>"+
                                "<td>&nbsp;</td>"+
                                "<td width='20%'>&nbsp;</td>"+
                                "<td width='20%'>&nbsp;</td>"+                                
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Correo electrónico:</div></td>"+
                                "<td colspan='2'>"+lista.get(3) +"</td>"+
                                "<td width='20%'>&nbsp;</td>"+                                
                                "<td width='20%'>&nbsp;</td>"+
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Calle:</div></td>"+
                                "<td colspan='4'>"+lista.get(4) +"</td>"+                                                                                                                  
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Número exterior:</div></td>"+
                                "<td>"+lista.get(5) +"</td>"+
                                "<td colspan='2'><div align='right'>Número interior:</div></td>"+
                                "<td width='20%'>"+lista.get(6) +"</td>"+                                
                            "</tr>"+
                            "<tr>"+
                                "<td><div align='right'>Delegación:</div></td>"+
                                "<td colspan='2'>"+lista.get(7) +"</td>"+
                                "<td width='20%'><div align='right'>C.P.</div></td>"+
                                "<td width='20%'>"+lista.get(8) +"</td>"+
                            "</tr>"+
                        "</table>  ";                       
                     
                     out.println(tabla);
        }
        
        
        
    }

}
